<?php

/**
* @author Anton "The MissSpell"
*
* Calculator of days difference
* 
* @param  date  $endDate
* @param  dare  $beginDate
*
*/
function daysDifference($endDate, $beginDate){
  
  /**
  * Extract the date string
  * explode the date by "-" and storing to array
  *
  */
  $dateParts1  = explode("-", $beginDate);
  $dateParts2  = explode("-", $endDate);
  
  /**
  * gregoriantojd() Converts a Gregorian date to Julian Day Count
  *
  */
  $startDate  = gregoriantojd($dateParts1[1], $dateParts1[2], $dateParts1[0]);
  $stopDate   = gregoriantojd($dateParts2[1], $dateParts2[2], $dateParts2[0]);
  
  return $stopDate - $startDate;
}


//echo daysDifference('2008-03-12','2008-03-09');
?>